package cn.ryh.filter.code.config;

import cn.ryh.filter.code.CodeFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author Rao
 * @Description
 * @create 2022-04-15 17:12
 */
@Configuration
public class CodeConfig {
    /**
     * 注册Filter
     *
     * @return
     */
    @Bean
    public FilterRegistrationBean<CodeFilter> codeFilter() {
        FilterRegistrationBean<CodeFilter> registration = new FilterRegistrationBean<>();
        registration.setFilter(new CodeFilter());
        //拦截所有
        registration.addUrlPatterns("/*");
        //设置该过滤器的优先级，数字越小，优先级越高
        registration.setOrder(1);
        return registration;
    }
}
